package com.jgybzx.entity;

import java.io.Serializable;
import java.util.Set;

/**
 * @author Jgybzx
 * @date 2021/7/30 14:21
 * des
 */
public class Role implements Serializable {
    private Integer roleId;

    private String roleName;

    private Set<Permission> permissions;
    private static final long serialVersionUID = 1L;

    public Role(Integer roleId, String roleName, Set<Permission> permissions) {
        this.roleId = roleId;
        this.roleName = roleName;
        this.permissions = permissions;
    }

    public Role() {
        super();
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName == null ? null : roleName.trim();
    }

    public Set<Permission> getPermissions() {
        return permissions;
    }

    public void setPermissions(Set<Permission> permissions) {
        this.permissions = permissions;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", roleId=").append(roleId);
        sb.append(", roleName=").append(roleName);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Role)) {
            return false;
        }

        Role role = (Role) o;

        if (getRoleId() != null ? !getRoleId().equals(role.getRoleId()) : role.getRoleId() != null) {
            return false;
        }
        return getRoleName() != null ? getRoleName().equals(role.getRoleName()) : role.getRoleName() == null;
    }

    @Override
    public int hashCode() {
        int result = getRoleId() != null ? getRoleId().hashCode() : 0;
        result = 31 * result + (getRoleName() != null ? getRoleName().hashCode() : 0);
        return result;
    }
}